using UnityEngine;
using System.Collections;

public class MButton : MControl
{
	
	public Texture view2;
	
	
    public void Start()
	{
		base.Start();
	}
	
	
	public virtual void OnEvent(Touch t)
	{
		touchPhase = t.phase;
		if( t.phase == TouchPhase.Began )
		{
			OnDown(t);
            gameObject.renderer.material.mainTexture = view2;
		}
		else if( t.phase == TouchPhase.Ended || t.phase == TouchPhase.Canceled )
		{
			if( OnUp(t) == 1 )
			{
				OnMClick();
			}
            gameObject.renderer.material.mainTexture = view;
		}
	}
	
	public virtual void OnMClick()
	{
		MUIManager.Instance().Event(Id, this);
	}
}

